// configureStore.js

// import { createStore } from "redux";
import { configureStore, EnhancedStore } from "@reduxjs/toolkit";
// import { composeWithDevTools } from "redux-devtools-extension";
import { persistStore, persistReducer } from "redux-persist";
import storage from "redux-persist/lib/storage"; // defaults to localStorage for web

import rootReducer from "./reducers";
import { RootStateI } from "../types/system";
// import { ActionTypeI } from "./actions";

const persistConfig = {
  key: "root",
  storage,
};

const persistedReducer = persistReducer(persistConfig, rootReducer);

// let store = createStore(persistedReducer);
// let store: EnhancedStore<Partial<RootStateI>, ActionTypeI> = configureStore({
let store: EnhancedStore<Partial<RootStateI>, any> = configureStore({
  reducer: persistedReducer,
  middleware: (getDefaultMiddleware) =>
    getDefaultMiddleware({
      serializableCheck: false,
    }),
});
let persistor = persistStore(store);

export { store, persistor };
